package com.ktgj.customer.api;

import com.ktgj.common.core.constant.ServiceNameConstants;
import com.ktgj.common.core.domain.R;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.customer.api.domain.*;
import com.ktgj.customer.api.domain.BankCard;
import com.ktgj.customer.api.domain.BusinessOrder;
import com.ktgj.customer.api.domain.Coupon;
import com.ktgj.customer.api.domain.CouponDto;
import com.ktgj.customer.api.domain.Customer;
import com.ktgj.customer.api.domain.CustomerCard;
import com.ktgj.customer.api.domain.Department;
import com.ktgj.customer.api.domain.Employee;
import com.ktgj.customer.api.factory.RemoteCustomerFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 会员服务
 * @author ruoyi
 */
@Repository
@FeignClient(contextId = "RemoteCustomerService", value = ServiceNameConstants.CUSTOMER_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class)
public interface RemoteCustomerService {

    /**
     * 根据部门id获取部门信息
     * @param deptId
     * @return
     */
    @GetMapping(value = "/department/{deptId}")
    public R<Department> getDepartmentInfo(@PathVariable("deptId") Long deptId);

    /**
     * 根据会员id获取会员信息
     * @param customerId
     * @return
     */
    @GetMapping(value = "/customer/{customerId}")
    public R<Customer> getCustomerInfo(@PathVariable("customerId") Long customerId);

    /**
     * 根据会员id查询详细信息
     * @param customerId
     * @return
     */
    @PostMapping("/customer/getCustomerId")
    public R<Customer> getCustomerId(@RequestParam("customerId") Long customerId);

    /**
     * 根据token获取当前登录的员工信息
     *
     * 请把token放在请求头中
     */
    @PostMapping(value = "/login/getLoginEmployeeByToken")
    public R<Employee> getLoginEmployeeByToken(@RequestParam("token")String token);

    /**
     * 根据员工id获取员工信息
     * @param map
     * @return
     */
    @PostMapping("/employee/getInfoById")
    public R<Employee> getInfoById(@RequestBody Map<String, Long> map);

    /**
     * 用户端app根据token获取当前登录的用户信息
     *
     * 请把token放在请求头中
     */
    @PostMapping(value = "/login/getLoginCustomerByToken")
    public R<Customer> getLoginCustomerByToken(@RequestParam("token")String token);

    /**
     * 花费积分、核销优惠卷、扣除预留款
     * 使用时判断R<String>.smg.equals("success")
     *
     * @param customerId      会员id
     * @param creditsNum      要扣减的积分
     * @param orderType       订单类型
     * @param orderId         订单id
     * @param orderSourceDesc 订单描述（客户端展示使用），例如机票 显示航程+航班号
     * @param couponId        使用优惠卷的id
     * @param usedDeposit     要扣除的预留款金额
     * @param employeeId      操作员工id（用户端没有操作员工，入参1L写死）
     * @return
     */
    @PostMapping("/record/spend")//会员id、要扣减的积分、订单类型、订单id、订单描述（客户端展示使用），例如机票 显示航程+航班号、使用优惠卷的id
    public R<String> spend(@RequestParam("customerId") Long customerId, @RequestParam("creditsNum") Long creditsNum, @RequestParam("orderType") String orderType,
                           @RequestParam("orderId") Long orderId, @RequestParam("orderSourceDesc") String orderSourceDesc, @RequestParam("couponId") Long couponId,
                           @RequestParam("usedDeposit") BigDecimal usedDeposit, @RequestParam("employeeId") Long employeeId);

    /**
     * 查看用户可用积分
     */
    @PostMapping("/record/queyUserCreditsNumByToken")
    public R<Long> queyUserCreditsNumByToken(@RequestParam("token") String token);

    /**
     * 查看用户可用积分（CRM）
     * @param customerId
     * @return
     */
    @PostMapping("/record/queyUserCreditsNumByCustomerId")
    public R<Long> queyUserCreditsNumByCustomerId(@RequestParam("customerId") Long customerId);

    /**
     * 卡号查询会员id
     * */
    @PostMapping("/customerCard/selectCustomerCard")
    public CustomerCard selectCustomerCard(@RequestParam("cardCode") String cardCode);

    /**
     * 获取会员预留款
     * @param token
     * @return
     */
    @PostMapping("/business/selectAvailableGold")
    public R<Long> queyUserDepositBusinessByToken(@RequestParam("token") String token);

    /**
     * 获取会员预留款（CRM）
     * @param customerId
     * @return
     */
    @PostMapping("/business/selectAvailableGoldByCustomerId")
    public R<Long> selectAvailableGoldByCustomerId(@RequestParam("customerId") Long customerId);

    /**
     * 根据金额推荐最优优惠券
     * @param token
     * @return
     */
    @PostMapping("/coupon/queyUserCouponByToken")
    public R<CouponDto> queyUserCouponByToken(@RequestParam("token") String token, @RequestParam("money") BigDecimal money);

    /**
     * 根据金额推荐最优优惠券(CRM)
     * @param customerId
     * @return
     */
    @PostMapping("/queyUserCouponById")
    public R<CouponDto> queyUserCouponById(@RequestParam("customerId") Long customerId, @RequestParam("money") BigDecimal money);

    /**
     * 查询vip通道订单(远程)
     * */
    @PostMapping("/customerCard/selectVipOrder")
    public CustomerCard selectVipOrder(@RequestParam("customerId") Long customerId);

    /**
     * 根据订单号查询会员Id(远程)
     * */
    @PostMapping("/businessOrder/selectBusinessOrderByOrdernum")
    public BusinessOrder selectBusinessOrderByOrdernum(@RequestParam("ordernum") String ordernum);

    @PostMapping("/travelers/queryByCustomerIdCommon")
    public R<CommonTravelersDto> queryByCustomerIdCommon(Long customerId);


    /**
     * 查询卡号
     * @param customerId
     * @return
     */
    @PostMapping("/customerCard/queryCardIdByCustomerId")
    public List<CustomerCard> queryCardIdByCustomerId(@RequestParam("customerId") Long customerId);

    @PostMapping("/travelers/queryPassengerByCustomerId")
    public List<CommonPassengerApi> queryPassengerByCustomerId(@RequestParam("customerId") Long customerId, @RequestParam("commonTrvelersId") Long commonTrvelersId, @RequestParam("certificateType") String certificateType);

    @PostMapping("/assistProduct/queryAssistProductList")
    public List<AssistProductApi> queryAssistProductList(@RequestBody Map<String, Object> map);

    @PostMapping("/assistProduct/assistProduct")
    public AssistProductVoApi assistProduct(@RequestBody Map<String, Object> map);

    @PostMapping("/login/updatetrainPassword")
    public int updatetrainPassword(@RequestParam("customerId") Long customerId, @RequestParam("trainPassword") String trainPassword);

    @PostMapping("/customer/update")
    public int update(@RequestBody Customer customer);

    /**
     * 会员常用旅客信息列表（远程）
     * */
    @PostMapping("/travelers/CustomerTravelerList")
    public List<CustomerTraveler> CustomerTravelerList(Long memberId);

    /**
     * 查询会员12306账号
     * @param customerId
     * @param accountType
     * @return
     */
    @PostMapping("/customeraccount/queryAccountIdAndAccountPassword")
    public R<CustomeraccountApi> queryAccountIdAndAccountPassword(@RequestParam("customerId") Long customerId, @RequestParam("accountType") String accountType);

    /**
     * 新增会员账号
     * @param customeraccount
     * @return
     */
    @PostMapping("/customeraccount/insert")
    public int insert(@RequestBody CustomeraccountApi customeraccount);

    /**
     * 修改会员12306密码
     * @param customeraccount
     * @return
     */
    @PostMapping("/customeraccount/updateAccountPassword")
    public int updateAccountPassword(@RequestBody CustomeraccountApi customeraccount);

    /**
     * 优惠券金额
     * @param couponId
     * @return
     */
    @PostMapping("/coupon/couponById")
    public R<Coupon> couponById(@RequestParam("couponId") Long couponId);

    /**
     * 根据会员权益id查询优惠卷信息
     */
    @PostMapping("/coupon/couponByCustomerRightDetailId")
    public R<CouponBO> couponByCustomerRightDetailId(@RequestParam("customerRightDetailId") Long customerRightDetailId);

    /**
     * 查询辅营产品价格
     * @param id
     * @return
     */
    @PostMapping("/assistProduct/queryAssistProduct")
    public R<AssistProductApi> queryAssistProduct(@RequestParam("id") Long id);

    /**
     * 根据id查询会员已绑定银行卡信息
     * */
    @PostMapping("/bankCard/selectBankCardBytBankCardId")
    public BankCard selectBankCardBytBankCardId(@RequestParam("bankCardId") Long bankCardId);

    /**
     * 会员已绑定银行卡列表
     * */
    @PostMapping("/bankCard/selectBankCardByMemberId")
    public List<BankCard> selectBankCardByMemberId(@RequestBody Map<String, Object> map);

    @PostMapping("/customer/getCustomerByMobile")
    public Customer getCustomerByMobile(String moblieId);

    /**
     * 删除乘车人
     * */
    @PostMapping("/travelers/delFrequentTraveler")
    public String delFrequentTraveler(@RequestParam("token") String token,
                                      @RequestParam("commonTrvelersId") Long commonTrvelersId);

    /**
     * 火车票添加乘车人
     *
     * @param token
     * @param information
     * @return
     */
    @PostMapping("/travelers/insertCommonTravelers")
    public int insertCommonTravelers(@RequestParam("token") String token, @RequestBody PassengerInformationApi information);

    /**
     * 火车票添加乘车人（CRM远程调用）
     * @param customerId
     * @param information
     * @return
     */
    @PostMapping("/travelers/insertCommonTravelersCrm")
    public int insertCommonTravelersCrm(@RequestParam("customerId") Long customerId, @RequestBody PassengerInformationApi information);

    /**
     * 修改常用旅客信息（远程调用）
     */
    @PostMapping("/travelers/edits")
    public int edits(@RequestBody CommonTravelersApi commonTravelers);

    /**
     * 查看用户可用预留款
     */
    @PostMapping("/business/depositBusiness")
    public AjaxResult depositBusiness(HttpServletRequest request);

    /**
     * 计算接口
     */
    @PostMapping("/util/calculationRemotely")
    public CalculationDTO calculationRemotely(@RequestBody CalculationVOApi calculationVOApi);

    /**
     * 机票-乘客列表
     * */
    @PostMapping("/travelers/fileCommonTravelers")
    public List<CommonTravelers> fileCommonTravelers(Map<String, Object> map);

    /**
     * 根据乘车人id查询证件信息
     * */
    @PostMapping("/passengerDocuments/selectDocuments")
    public List<PassengerDocuments> selectDocumentsByCommontrvelersId(Map<String, Object> map);

    /**
     * 后端——查询常用旅客的证件
     * @param commontrvelersId
     * @return
     */
    @PostMapping("/passengerDocuments/backSelectPassengerDocumentsBack")
    public R<PassengerDocuments> backSelectPassengerDocumentsBack(@RequestParam("commontrvelersId") Long commontrvelersId);

    /**
     * 远程-银行名称模糊查询
     * */
    @PostMapping("/bank/selectBankLike")
    public String selectBankLike(@RequestBody Map<String, Object> map);

    /**
     * 会员信息查id
     * */
    @PostMapping("/customer/customerByCustomerName")
    public Long customerByCustomerName(@RequestBody VipCustomerVo vipCustomerVo);

    /**
     * 查询会员的所有会员卡
     * */
    @PostMapping("/customerCard/customerCardList")
    public CustomerCard customerCardList(@RequestBody Map<String, Object> map);

    /**
     * 根据会员姓名查询会员信息
     * @param customer
     * @return
     */
    @PostMapping("/customer/customerList")
    public List<Customer> customerList(@RequestBody Customer customer);

    /**
     * 获取卡详细信息
     */
    @PostMapping("/card/cardInfo")
    public Card cardInfo(@RequestBody Map<String, Object> map);

    @PostMapping("/bankCard/selectBackCardNum")
    public BankCard selectBackCardNum(@RequestBody Map<String, Object> map);

    /**
     * 卡号查银行代码
     * */
    @PostMapping("/bankCard/backCard")
    public String backCard(@RequestBody Map<String, Object> map);

    /**
     * 酒店优惠券列表
     * */
    @PostMapping("/coupon/couponList")
    public List<HotelCouponVo> couponList(@RequestBody Map<String, Object> map);

    /**
     * 新增会员消息
     */
    @PostMapping("/customer/addCustomerMessage")
    public int addCustomerMessage(@RequestBody Map<String,String>map);
    /**
     * 修改会员消息状态
     */
    @PostMapping("/customer/updCustomerMessage")
    public int updCustomerMessage(@RequestBody Map<String,String>map);

    /**
     * 火车票银行卡支付查询银行卡信息
     * */
    @PostMapping("/bankCard/backCardNum")
    public BankCard backCardNum(@RequestBody String cardNumber);

    /**
     * 新增银行卡（远程）
     * */
    @PostMapping("/bankCard/bankCard")
    public int bankCard(@RequestBody BankCard bankCard);

    /**
     * 根据会员信息查id
     * */
    @PostMapping("/customer/customerIdApi")
    public CustomerIdVoApi customerIdApi(@RequestBody CustomerIdVoApi customerIdVo);

    /**
     * 退款（添加会员预留款记录）
     */
    @PostMapping("/business/refund")
    public int refund(@RequestBody DepositBusinessApi depositBusiness);

    /**
     * 员工姓名获取id
     * */
    @PostMapping("/employee/employeeIdList")
    public List<Long> employeeIdList(@RequestBody Map<String, Object> map);

    /**
     * 获取在线员工信息列表
     * @return
     */
    @PostMapping("/employee/getOnlineEmployeeList")
    List<Employee> getOnlineEmployeeList();

    /**
     * 使用员工信息ID列表来查询会员信息列表
     * @param lstIds
     * @return
     */
    @PostMapping("/employee/getEmployeeListByIds")
    List<Employee> getEmployeeListByIds(@RequestBody List<Long> lstIds);


    /**
     * 员工id获取姓名
     * */
    @PostMapping("/employee/employeeNameList")
    public Employee employeeNameList(@RequestBody Map<String, Object> map);

    /**
     * 新增预留款业务
     */
    @PostMapping("/business/addReserveMoney")
    public Long addReserveMoney(@RequestBody DepositBusinessApi depositBusinessApi);

    /**
     * 获取指定部门的所有员工id
     * */
    @PostMapping("/employee/employeeVipIdList")
    public List<Long> employeeVipIdList(@RequestBody Map<String, Object> map);

    /**
     * 查询员工所在部门（远程）
     * */
    @PostMapping("/department/department")
    public Department department(@RequestBody Map<String, Object> map);

    /**
     * id获取部门名称（远程）
     * */
    @PostMapping("/department/deptName")
    public Department deptName(@RequestBody Map<String, Object> map);

    /**
     * 通过银行卡号获取银行信息(远程)
     * */
    @PostMapping("/bankCard/bankNames")
    public BankApi bankNames(@RequestBody Map<String, Object> map);

    /**
     * 新增财务会员退款信息
     */
    @PostMapping("/refundment/add")
    public R<AjaxResult> add(@RequestBody FinanceOrderRefundment financeOrderRefundment);

    /**
     * 新增保险记录(远程)
     * */
    @PostMapping("/insuranceType/insertInsuranceRecordBack")
    public InsuranceReturnVoApi insertInsuranceRecordBack(@RequestBody ProductVoApi productVo);

    /**
     * 新增财务会员退款信息(远程)
     */
    @PostMapping("/refundment/save")
    public int save(@RequestBody FinanceOrderRefundment financeOrderRefundment);

    /**
     * 提交审核的批次号顺序递增
     * */
    @PostMapping("/refundment/number")
    public int number();

    /**
     * 修改德付通保险状态（远程）
     * */
    @PostMapping("/insuranceType/updateStart")
    public boolean updateStart(@RequestBody InsuranceRecord insuranceRecord);

    /**
     * 当前会员可支配的预留款
     * */
    @PostMapping("/business/dominateGold")
    public BigDecimal dominateGold(@RequestBody Map<String, Object> map);

    /**
     * 当前会员可支配积分
     * */
    @PostMapping("/record/dominateIntegral")
    public Long dominateIntegral(@RequestBody Map<String, Object> map);

    /**
     * 当前会员可支配的预留款
     * */
    @PostMapping("/business/BackDominateGold")
    public BigDecimal BackDominateGold(HttpServletRequest request);

    /**
     * 当前会员可支配积分
     * */
    @PostMapping("/record/BackDominateIntegral")
    public Long BackDominateIntegral(HttpServletRequest request);

    /**
     * 查询会员是否有贵宾厅无限券
     * */
    @PostMapping("/customerRightdetail/infiniteVIPHall")
    public boolean infiniteVIPHall(@RequestParam("id") Long id);

    /**
     * 订单号查预留款记录
     * */
    @PostMapping("/business/audit")
    public boolean audit(@RequestParam("orderNum") String orderNum);

    /**
     * 预留款审核（系统管理员）
     * */
    @PostMapping("/business/manageAudit")
    public boolean manageAudit(@RequestBody Map<String, Object> map);

    /**
     * 新增会员权益
     * @param customerRightdetail
     * @return
     */
    @PostMapping("/customerRightdetail/add")
    public R<AjaxResult> addCustomerRightdetail(@RequestBody CustomerRightdetail customerRightdetail);
}
